<div style="height:550px;width: 100%" id="sidebar_left">
<div class="m_leftbar">
    <dl>
				<dt>
					<a  href="#">互动交流</a>
				</dt>
    </dl>
    <ul>
         <?php
         $act=$_POST['act'];
        if($_SESSION['type']=='')
        {
            fs_showmsg('请先登录!','?');
        }
       ?>
         <li><a href="?do=message">发邮件</a></li>
        <li><a href="?do=inbox">已发邮件</a></li>
         <li><a href="?do=groupmail&c=already">班级邮件</a></li>
        <li><a href="?do=draft">草稿箱</a></li>
    </ul>
</div>
<div class="m_rightbar">
    <div class="m_title">草稿箱</div>
            <div class="m_sendbox">
                <form action="" method="post" name="form1" style="margin:0px">
                <table cellspacing="0" cellpadding="0" id="messagelist">
                    <tr class="td_head" >
                        <td style="width: 5%">选中</td>
                        <td>收件人</td>
                        <td>主题</td>
                        <td>上次编辑时间</td>
                        <td>操作</td>
                    </tr>
                        <?php
                            $sql ="select m.object,m.m_id,m.sendtime,b.realname from nettteach_message as m inner join nettteach_member as b on m.m_to=b.id  where m_from=".$_SESSION['sid']." and is_save=1 order by m_id desc";
                            $query  =$db->query($sql);
                            while($row = $db->fetch_array($query))
                            {?>
                        <tr class="list_list" >
                            <td><input name='id' type="checkbox" value=<?php echo($row['m_id']);?>></td>
                            <td><?php echo $row['realname'] ?></td>
                            <td><?php echo $row['object']?></td>
                            <td><?php echo date('Y-m-d H:i:s',$row['sendtime'])?></td>
                            
                            <td><a href="?do=editmail&id=<?php echo $row['m_id']?>">编辑</a></td>
                             </tr>
                                <?php
                            }
                        ?>
                </table>
                </form>   
                <div style="padding-left: 10px;line-height: 27px;">
                    <INPUT onclick=CheckAll('selectAll',this) type=checkbox value=on name=chkall>全选
                    <input type="checkbox" name="invest" value="checkbox" onClick="CheckAll()">反选
                    <input type="checkbox" name="invest" value="checkbox" onClick="CheckAll('deleteAll',0)">全不选&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type=submit name="delete" id="delete" style="font-size:9pt;width:50px;" value="删除" onclick="getCheck()" >
                </div>
            </div>
</div>
</div>
<script type="text/javascript">
function getCheck(){
     var result=new Array();
     if(!document.form1.id.length){ 
        if(document.form1.id.checked){
             result.push(document.form1.id.value)
             }
    } 
    else{ 
         for(i=0;i<document.form1.id.length;i++){
             if(document.form1.id[i].checked){
             result.push(document.form1.id[i].value)
             }
         }
    }
//     alert(result);
if(confirm("是否删除")){
     if(result ==''){
         alert("请选择要删除的邮件");
         return false;
     }else{
            window.location.href="?do=draft&deid="+result;
     }
}
}
</script>
<?php
if($_SESSION['sid']!='' && $_GET['deid']!='')
{
    $userid = $_SESSION['sid'];
    $deleteid = $_GET['deid'];
    $deid=explode(",", $deleteid);
    if($deid!='')
    {
        foreach ($deid as $deid){
                $update_sql  = "delete from nettteach_message where m_from=".$userid." and m_id=".$deid;//删除草稿
                $db->query($update_sql);
        }
                fs_showmsg('删除成功');
    }
    else
    {
        fs_showmsg('请选择要删除的草稿!');
    }
    
}
?>
